package edu.sctu.wangxiaoqiang.projectOne;

import java.util.HashMap;

import java.util.Scanner;


/**
 * Created by user06 on 2015/5/31.
 */
public class Autosell {
    String origin;
    String destination;
    int number;
    HashMap<Integer,String> rode = new HashMap<Integer,String>();
    Scanner sc = new Scanner(System.in);

    public Autosell(){}
    public Autosell(String origin,int number){
        this.origin = origin;
        this.number = number;
    }

    /**
     * 初始化线路
     */
    public HashMap setRode(){
        rode.put(1,"犀浦");
        rode.put(2,"茶店子");
        rode.put(3,"一品天下");
        rode.put(4,"蜀汉路");
        rode.put(5,"天府广场");
        rode.put(6,"东大路");
        rode.put(7,"成渝立交");
        rode.put(8,"惠王陵");
        rode.put(9,"成都行政学院");
        rode.put(10,"书房");
        rode.put(11,"龙泉");
        return rode;
    }
    /**
     * 输入终点进行买票
     */
    public void buyTicket (){
        System.out.println("地铁线路：犀浦(1号)-茶店子(2号)-一品天下(3号)-蜀汉路(4号)-天府广场(5号)-东大路(6号)-" +
                "成渝立交(7号)-惠王陵(8号)-成都行政学院(9号)-书房(10号)-龙泉(11号)"+"\n"+"请输入终点站！");
        HashMap<Integer,String> rode = setRode();
        destination = sc.next();
        for(int i = 1;i<=rode.size();i++) {
            if ( rode.get(i).equals(destination)) {
                int zhanshu = Math.abs(i - number);
                    if(zhanshu > 0 && zhanshu<2){
                        System.out.println("票价2元，请投币！");
                    }else if(zhanshu < 6){
                        System.out.println("票价4元，请投币！");
                    }else if(zhanshu < 8){
                        System.out.println("票价5元，请投币！");
                    }else {
                        System.out.println("票价6元，请投币！");
                    }
            }
        }
    }

    /**
     * 给卡充值
     */
    public int reacharge(int balance){
        int price;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您想充值的金额！");
        price = scanner.nextInt();
        balance =balance + price;
        return balance;
    }

}
